package cn.changeforyou.web.cloud.auth.rpcimpl;

import cn.changeforyou.web.cloud.auth.manager.LoginManager;
import cn.changeforyou.web.cloud.auth.service.ServiceInfoService;
import cn.changeforyou.web.cloud.auth.service.SourceInfoService;
import cn.changeforyou.web.cloud.auth.service.UserService;
import cn.changeforyou.web.cloud.rpc.service.auth.AuthRpc;
import cn.changeforyou.web.cloud.rpc.service.auth.dto.ServiceInfoDTO;
import cn.changeforyou.web.cloud.rpc.service.auth.dto.SourceInfoDTO;
import cn.changeforyou.web.cloud.webBase.auth.AuthModel;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
@Service
public class AuthRpcImpl implements AuthRpc {

    @Resource
    private UserService userService;

    @Resource
    private ServiceInfoService serviceInfoService;

    @Resource
    private LoginManager loginManager;

    @Resource
    private SourceInfoService sourceInfoService;

    @Override
    public AuthModel parseToken(String token) {
        return loginManager.parseToken(token);
    }

    @Override
    public List<ServiceInfoDTO> getServiceInfos() {
        return serviceInfoService.listDTO();
    }

    @Override
    public List<SourceInfoDTO> getSourceInfos() {
        return sourceInfoService.listDTO();
    }

}
